#include "Eventloop.h"
#include "Epoller.h"
#include "Channel.h"

namespace liu
{

	Eventloop::Eventloop()
		:m_unipEpoller(make_unique<Epoller>(this))
	{

	}

	Eventloop::~Eventloop()
	{

	}

	void Eventloop::UpdateChannel(Channel* pChannel)
	{
		m_unipEpoller->UpdateChannel(pChannel);
	}

	void Eventloop::Loop()
	{	
		while (true)
		{
			m_vecActiveChannels.clear();
			m_unipEpoller->PollWait(10000,m_vecActiveChannels);

			for (auto& x:m_vecActiveChannels)
			{	
				x->handleEvent();
			}
		}
	}

}